package com.rd.student.dashuju.sunwenzhuo.Test1.fighting;

import java.util.Random;

public class FightingGame1 {
/*    private String name;
    private int blood;


    public FightingGame() {

    }

    public FightingGame(String name, int blood) {

    }



    public void setBlood(int blood) {
        this.blood = blood;
    }

    public void setName(String name) {
        this.name = name;
    }
*/

    public static void fight(int blood1,int blood2,String name1,String name2) {


        int min = 1;
        int max = 100;
        Random random = new Random();
        while (true) {

            int hurt1 = min + random.nextInt(max - min);
            int hurt2 = min + random.nextInt(max - min);


            if (blood1 > 0) {
                blood1 = blood1-hurt1;
                System.out.println(name2 + "举起拳头打了" +name1+ "一下,造成了" + hurt1 + "点伤害," + name1 + "还剩下" + blood1 + "点血");

            } else if (blood1 <= 0) {
                System.out.println(name2 + "K.O了" +name1);
                break;
            }
            if (blood2 > 0) {
                blood2 =blood2 - hurt2;
                System.out.println(name1 + "举起拳头打了" + name2+ "一下,造成了" + hurt2 + "点伤害," +name2 + "还剩下" + blood2 + "点血");
            } else if (blood2 <= 0) {
                System.out.println(name1 + "K.O了" + name2);
                break;
            }
        }

    }

}
